package com.example.jobback.websocket.common;

import lombok.Data;

import java.util.Objects;

/**
 * @ClassName: UserKey
 * @Description: 用户键，包含用户ID和角色。userid和role才能确定唯一
 * @Author: lhb
 * @Date: 2025/5/24
 */
@Data
public class UserRole {
    private final Long userId;
    private String role;

    public UserRole(Long userId, String role) {
        this.userId = userId;
        this.role = role;
    }

    public Long getUserId() {
        return userId;
    }

    public String getRole() {
        return role;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserRole userKey = (UserRole) o;
        return Objects.equals(userId, userKey.userId) &&
                Objects.equals(role, userKey.role);
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId, role);
    }

    @Override
    public String toString() {
        return "UserKey{" +
                "userId='" + userId + '\'' +
                ", role=" + role +
                '}';
    }
}
